#include <stdio.h>
#define MAX_SIZE 10000000

int hash[MAX_SIZE] = {0};

int main() {
    int k,q = 0;
    while (scanf("%d", &k) && k!= -1) {
        hash[k] += 1;
    }
    while (scanf("%d", &k) && k!= -1) {
        if (hash[k] >= 1 ) {
            printf("%s%d", q==0?"":" ",k);
            hash[k]--;
            q++;
        }
    }
    if (q == 0) printf("NULL");
}